<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;

class Coupon extends Model
{
	use HasDateTimeFormatter;
    public $timestamps = false;

    protected $fillable = ['user_id','coupon_config_id', 'deduction_ratio', 'used_quota', 'receive_time','expiration_time'];


    public function coupon_config(): BelongsTo
    {
        return $this->belongsTo(CouponConfig::class);
    }

    /**
     * 用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }


    public function coupon_log()
    {
        return $this->hasMany(CouponsLog::Class);
    }

}
